package algos;

public class LidstoneLaw extends EstimationFunction {

    private final double a;
    private final double lambda;

    public LidstoneLaw(NGramModel model, double a, double lambda) {
        super(model);
        this.a = a;
        this.lambda = lambda;
    }

    @Override
    public double p(int wordIndex) {
        double result = (model.predict(wordIndex) + a) / (model.getNTrains() + lambda * model.getBins().doubleValue());
        return result;
    }
}
